/**
 * PhoneBlacklist模型 - 用于存储电话黑名单
 */
const { DataTypes } = require('sequelize');

module.exports = (sequelize) => {
  const PhoneBlacklist = sequelize.define('PhoneBlacklist', {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    phoneNumber: {
      type: DataTypes.STRING(30),
      allowNull: false,
      comment: '被拦截的电话号码'
    },
    reason: {
      type: DataTypes.STRING(255),
      allowNull: true,
      comment: '拦截原因'
    },
    status: {
      type: DataTypes.ENUM('active', 'inactive'),
      allowNull: false,
      defaultValue: 'active',
      comment: '拦截状态'
    },
    createdBy: {
      type: DataTypes.STRING(50),
      allowNull: true,
      comment: '创建者'
    }
  }, {
    tableName: 'phone_blacklist',
    timestamps: true,
    indexes: [
      {
        unique: true,
        fields: ['phoneNumber']
      }
    ]
  });

  return PhoneBlacklist;
}; 